textlayout: avoid double-free when adding preedit color
authorDaiki Ueno <ueno@unixuser.org>
Wed, 3 Jul 2013 10:03:30 +0000 (19:03 +0900)
committerDaiki Ueno <ueno@unixuser.org>
Tue, 9 Jul 2013 04:21:17 +0000 (13:21 +0900)
In add_preedit_attrs, don't free foreground/background colors already
set in the underlying text attributes (style).  They will be free'd by
release_style.

https://bugzilla.gnome.org/show_bug.cgi?id=703533

gtk/gtktextlayout.c

index f87714bcc7466708ff42a99ebc018d5f0a77c021..f72f384973577978a0045d57d2942526e0e6bb3f 100644 (file)
@@ -1887,6 +1887,11 @@ add_preedit_attrs (GtkTextLayout     *layout,
        continue;
 
       pango_attr_iterator_get_font (iter, font_desc, &language, &extra_attrs);
+
+      if (appearance.rgba[0])
+       appearance.rgba[0] = gdk_rgba_copy (appearance.rgba[0]);
+      if (appearance.rgba[1])
+       appearance.rgba[1] = gdk_rgba_copy (appearance.rgba[1]);
       
       tmp_list = extra_attrs;
       while (tmp_list)
@@ -1947,6 +1952,11 @@ add_preedit_attrs (GtkTextLayout     *layout,
                          attrs, start + offset,
                          size_only, TRUE);
       
+      if (appearance.rgba[0])
+       gdk_rgba_free (appearance.rgba[0]);
+      if (appearance.rgba[1])
+       gdk_rgba_free (appearance.rgba[1]);
+
       pango_font_description_free (font_desc);
     }
   while (pango_attr_iterator_next (iter));